﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Enterprise.Management.Caches;
using System.Web.Routing;
using Enterprise.Management.Data;
using Enterprise.Management.Controllers;

namespace Enterprise.Management.FilterAttributes
{
    public class CategoryFunctionAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            int? categoryId = BranchCategoryCache.BranchCategoryId;
            if (!categoryId.HasValue)
            {
                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new
                {
                    controller = "Home",
                    action = "Index"
                }));
            }
        }
    }
}